<?php


namespace app\admin\validate;


use think\Validate;

/**
 * Class ArticleCategory
 * @package app\admin\validate
 * @author Mr.Liu Wuchen
 * @create 2021-06-23 13:46
 */
class ArticleCategory extends Validate
{

    /**
     * 验证规则
     * @var string[]
     */
    protected $rule = [
        'id'   => 'require|number|gt:0',
        'name' => 'require|unique:admin_article_category|max:30',
        'desc' => 'max:120',
    ];

    /**
     * 错误信息
     * @var string[]
     */
    protected $message = [
        'id.require'   => '参数错误',
        'id.number'    => '参数错误',
        'id.gt'        => '参数错误',
        'name.require' => '请填写分类名称',
        'name.unique'  => '分类名称已经存在',
        'name.max'     => '分类名称最多30个字符',
        'desc.max'     => '描述最多120个字符',
    ];


    /**
     * 验证场景
     * @var string[]
     */
    protected $scene = [
        'create' => ['name', 'desc'],
        'update' => ['name', 'desc', 'id'],
    ];

}